% 定义 x 范围
x = linspace(0.001, 1, 20000);

% 计算 cond_f(x)
cond_f = @(x) abs(x ./ (1-exp(x)));
eps=1e-7;
cond_A = @(x) abs(x ./ (exp(x) *(1+eps)- 1));

% 计算值
y_cond_f = cond_f(x);
y_cond_A = cond_A(x);

% 绘制图形
figure;
plot(x, y_cond_f, 'b-', 'LineWidth', 2);
hold on;
plot(x, y_cond_A, 'r--', 'LineWidth', 2);
xlabel('x');
ylabel('Condition Number');
legend('cond_f(x)', 'Estimated cond_A(x)');
title('Condition Numbers of f(x) and Algorithm A');
grid on;

% 显示图形
hold off;